<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Factories\HasFactory;

class BillPay extends BaseModel
{
    use HasFactory;

    public $table = 'bill_pay';

    public $guarded = [];

    public $appends = ['payment_name'];

    public $casts = [
        'created_at' => 'date:Y-m-d H:i:s'
    ];

    public function bill()
    {
        return $this->belongsTo(Bill::class);
    }

    public function getPaymentNameAttribute()
    {
        // 1线下收款-微信，2线下收款-支付宝，3线下收款-银行卡, 4线上微信, 5线上支付宝
        switch ($this->payment) {
            case 0:
                return '房东充值';
            case 1:
                return '线下收款-微信';
            case 2:
                return '线下收款-支付宝';
            case 3:
                return '线下收款-银行卡';
            case 4:
                return '线上微信';
            case 5:
                return '线上支付宝';
            case 6:
                return '代客充值线上微信';
            case 7:
                return '代客充值线上支付宝';
        }
        return '未定义';
    }
}
